<template>
    <div>
        <p>msg_id:{{msgDetial.msg_id}}</p>
        <p>msg:{{msgDetial.msg}}</p>
        <p>msg_url:{{msgDetial.msg_url}}</p>
    </div>
</template>

<script>
    export default {
        name: "MessageDetial",
        props:{
            news:Array
        },
        data () {
            return {
                msgDetial:{
                    msg_id:'',
                    msg:'',
                    msg_url:'',
                }
            }
        },
        mounted () {
            let msgId=this.$route.params.msg_id*1;
            this.lastid=this.$route.params.msg_id;
            console.log(msgId)
            this.msgDetial=this.news.find(item => {
                return item.msg_id === msgId;
            })
        },
        watch :{
            $route : function (newValue) {
                let msgId=newValue.params.msg_id*1;
                this.msgDetial=this.news.find(item => {
                    return item.msg_id === msgId;
                })
            }
        }
        /*activated () {
            console.log(this.lastid)
            if(this.lastid!=this.$route.params.msg_id){
                this.msgDetial=this.news.find(item => {
                    return item.msg_id === this.$route.params.msg_id;
                })
                this.lastid=this.$route.params.msg_id;
            }
        }*/

    }
</script>

<style lang="stylus" scoped>

</style>